package com.lihao.wanandroid.app.weight.banner

import android.view.View
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.lihao.wanandroid.R
import com.lihao.wanandroid.data.model.BannerResponse
import com.zhpan.bannerview.holder.ViewHolder

/**
 * Created by lihao on 2020/6/11.
 * Describe:
 */
class HomeBannerViewHolder : ViewHolder<BannerResponse> {

    override fun getLayoutId(): Int {
        return R.layout.banner_item_home
    }

    override fun onBind(itemView: View, data: BannerResponse?, position: Int, size: Int) {
        val img = itemView.findViewById<ImageView>(R.id.bannerImage)
        Glide.with(img.context.applicationContext)
            .load(data?.imagePath)
            .transition(DrawableTransitionOptions.withCrossFade(500))
            .into(img)
    }
}